﻿using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFStudy.PrismStudy.ViewModels
{
    /// <summary>
    /// 导航必须实现接口INavigationAware
    /// </summary>
    public class NavigateBViewModel:BindableBase,INavigationAware
    {
        #region 标题

        /// <summary>
        /// 标题
        /// </summary>
        private string _title;

        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }

        #endregion 标题 

        public NavigateBViewModel()
        {

        }

        /// <summary>
        /// 每次重新导航的时候，该实例是否重用原来的实例
        /// </summary>
        /// <param name="navigationContext"></param>
        /// <returns></returns>
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }

        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="navigationContext"></param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            var title = navigationContext.Parameters.GetValue<string>("Title");        
            Title = title;
        }
    }
}
